﻿using ModernUILogViewer.ViewModel;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace ModernUILogViewer.Converters
{
    [ValueConversion(typeof(int), typeof(string))]  
    class IndexToFilenameConverter : DependencyObject, IValueConverter
    {
        public IList<FileViewModel> Files
        {
            get { return (IList<FileViewModel>)GetValue(FilesProperty); }
            set { SetValue(FilesProperty, value); }
        }

        public static readonly DependencyProperty FilesProperty =
            DependencyProperty.Register("Files", typeof(IList<FileViewModel>), typeof(IndexToFilenameConverter));
        
        public object Convert(object value, Type TargetType, object parameter, CultureInfo culture)
        {
            int idx = (int)value;

            return Files[idx].Filename;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return new NotImplementedException();
        }
    }
}
